/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mb.config;

import java.util.Hashtable;

/**
 *
 * @author thanh.nguyenchi
 */
public class ConstantsMsg {
        
    public static final String STR_EN_LANG = "EN";
    public static final String STR_VN_LANG = "VN";
    
    public static final int INT_SUCESSFUL_CODE = 0;
    public static final int INT_INVALID_VERSION_CODE = 1;
    public static final int INT_SERVER_LINK_CODE = -10;
    public static final int INT_NO_DATA_FOUND = -1000;
    
    public static final int INT_DATA_SUCESSFUL_CODE = 1;
    public static final String STR_ATM_QUERY = "_atm_";
    public static final String STR_BRA_QUERY = "_bra_";
    // hash table error msg
    public static Hashtable<Integer,String> errorEnMessages;
    public static Hashtable<Integer,String> errorVnMessages;
    
    public static void initErrorEnMsg(){
        errorEnMessages = new Hashtable<Integer, String>();
        errorEnMessages.put(INT_INVALID_VERSION_CODE,"Invalid app version.");
        errorEnMessages.put(INT_SERVER_LINK_CODE,"Invalid server config.");
        errorEnMessages.put(INT_NO_DATA_FOUND,"No data found.");
    }
    
    public static void initErrorVnMsg(){
        errorVnMessages = new Hashtable<Integer, String>();
        errorVnMessages.put(INT_INVALID_VERSION_CODE,"Sai version.");
        errorVnMessages.put(INT_SERVER_LINK_CODE,"Sai thong tin server.");
        errorVnMessages.put(INT_NO_DATA_FOUND,"Khong co du lieu phu hop.");
    }
    
    public static String getMsg(int iErrorCode,String lang){
        if (lang.equals(STR_EN_LANG)){
            return errorEnMessages.get(iErrorCode);
        }
        else if (lang.equals(STR_VN_LANG)){
            return errorVnMessages.get(iErrorCode);
        }
        else return "";
    }
    
    
    public static String getErrMsg(int iErrorCode,String lang){
        try{
            String  errMsg = getMsg(iErrorCode,lang);
            if (errMsg.length() <= 0){
                errMsg = "Error code is undefined.";
            }
            return errMsg;
        }
        catch (Exception ex){
            return "Error code is not define.";
        }
    }
}
